package tw.miku.protocol.codec.gold;

import java.nio.charset.CharacterCodingException;

import org.apache.mina.core.buffer.IoBuffer;

import tw.miku.constants.ProtocalConstants;
import tw.miku.protocol.codec.AbstractResponseMessagePack;

public class GoldCompleteResponsePack extends AbstractResponseMessagePack
{

	public boolean result;
	public int direct;
	public long userId;
	
	public GoldCompleteResponsePack()
	{
	}

	@Override
	public IoBuffer encode() throws CharacterCodingException
	{
		IoBuffer buf = IoBuffer.allocate(14);
		buf.putUnsignedInt(10);
		buf.putShort(getTag());
		buf.putShort((short) 0);
		buf.putUnsignedInt(userId);
		buf.put((byte) (result?0:1));
		buf.put((byte) direct);
		buf.flip();
		return buf;
	}
	
	@Override
	public short getTag()
	{
		return ProtocalConstants.GOLD_COMPLETE;
	}

}
